home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Light ROM 1
/
LIGHT-ROM 1 (Amiga Library Services)(1994).iso
/
ffdisks
/
d956.lha
/
SetDefMon
/
SetDefMon.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-10-29
|
5KB
|
173 lines
;/* DICE invocation sequence
stack 50000
dcc setdefmon.c -v -mi -ms -r -proto -mD -c -3.0 -no-env
dlink setdefmon.o -osetdefmon -v
protect setdefmon +p
quit 0 ; */
/* SetDefMon - sets the systems default monitor from wb/cli */
/* (w) 1992-1993 by Franz_Schwarz@mil.ka.sub.org */
/* Franz Schwarz FIDO 2:2476/506.18 */
/* version history */
/* 21 Dec 92 initial release 1.0 */
/* 15 Jan 93 1.1 added modification of GfxBase->DisplayFlags */
/* added Disable()/Enable() to modify GfxBase */
/* 12 Jul 93 1.1a modified to use DICE #pragma calls */
/* the executable is now pure, reentrant. */
/* 09 Sep 93 1.2 added support for SUPER72, DBLNTSC, DBLPAL */
/* now requires 3.0 Includes */
#include <graphics/gfxbase.h>
#include <graphics/displayinfo.h>
#include <intuition/intuition.h>
#include <workbench/startup.h>
#include <workbench/workbench.h>
#include <exec/execbase.h>
#include <exec/alerts.h>
#include <exec/ports.h>
#include <proto/exec.h>
#include <proto/intuition.h>
#include <proto/dos.h>
#include <proto/icon.h>
#include <proto/graphics.h>
#define NUM_MODES 6
LONG Main (VOID);
LONG
Start (VOID)
{
return Main ();
};
const char vers[] = "\0$VER: SetDefMon 1.2 (9.9.93)";
const char tmpl[] = "PAL/S,NTSC/S,EURO36/S,SUPER72/S,DBLNTSC/S,DBLPAL/S";
const char *const modenames[] =
{"PAL", "NTSC", "EURO36", "SUPER72", "DBLNTSC", "DBLPAL"};
const ULONG monitors[NUM_MODES] =
{PAL_MONITOR_ID, NTSC_MONITOR_ID, EURO36_MONITOR_ID, SUPER72_MONITOR_ID,
DBLNTSC_MONITOR_ID, DBLPAL_MONITOR_ID};
const char vblank[NUM_MODES] =
{50, 60, 70, 70, 60, 50};
const UWORD flags[NUM_MODES] =
{PAL, NTSC, NTSC, NTSC, NTSC, PAL};
#define NEED_AGA ((1<<4) + (1<<5))
struct ArgsT
{
ULONG larr[NUM_MODES];
};
const struct ArgsT cargs =
{0, 0, 0, 0, 0, 0};
LONG
Main (VOID)
{
APTR IntuitionBase, DOSBase, IconBase;
struct ExecBase *SysBase;
struct GfxBase *GfxBase;
LONG i = 0, mon = -1;
struct RDArgs *rda;
struct Process *me;
struct DiskObject *dskobj;
struct WBStartup *msg;
struct ArgsT args;
struct Rectangle r;
BPTR lock;
LONG rc = 20;
args = cargs;
SysBase = *(VOID **) 0x00000004;
if (!((me = (struct Process *) FindTask (NULL))->pr_CLI))
{
WaitPort (&me->pr_MsgPort);
msg = (struct WBStartup *) GetMsg (&me->pr_MsgPort);
}
if (DOSBase = OpenLibrary ("dos.library", 37))
{
if (GfxBase = OpenLibrary ("graphics.library", 37))
{
if (IntuitionBase = OpenLibrary ("intuition.library", 37))
{
if (!me->pr_CLI)
if (IconBase = OpenLibrary ("icon.library", 37))
{
lock = CurrentDir (msg->sm_ArgList->wa_Lock);
if (dskobj = GetDiskObjectNew (msg->sm_ArgList->wa_Name))
{
for (; i < NUM_MODES; i++)
if (FindToolType (dskobj->do_ToolTypes, modenames[i]))
mon = (mon == -1 ? i : -2);
FreeDiskObject (dskobj);
}
CurrentDir (lock);
CloseLibrary (IconBase);
}
else
Alert (AT_Recovery | AG_OpenLib | AO_IconLib | AN_Unknown);
else if (rda = ReadArgs (tmpl, args.larr, NULL))
{
for (; i < NUM_MODES; i++)
if (args.larr[i])
mon = (mon == -1 ? i : -2);
FreeArgs (rda);
}
switch (mon)
{
case -1:
SetIoErr (ERROR_REQUIRED_ARG_MISSING);
break;
case -2:
SetIoErr (ERROR_TOO_MANY_ARGS);
break;
default:
if (!ModeNotAvailable (monitors[mon] | HIRES_KEY) &&
QueryOverscan (monitors[mon] | HIRES_KEY, &r, OSCAN_TEXT))
{
if (((1 << mon) & NEED_AGA) ?
((GfxBase->ChipRevBits0 & (GFXF_AA_ALICE | GFXF_AA_LISA))
== (GFXF_AA_ALICE | GFXF_AA_LISA)) : TRUE)
{
Disable ();
GfxBase->DisplayFlags &= ~(NTSC | PAL);
GfxBase->DisplayFlags |= flags[mon];
GfxBase->NormalDisplayColumns = r.MaxX + 1;
GfxBase->NormalDisplayRows = r.MaxY + 1;
GfxBase->monitor_id = monitors[mon] >> 16;
SysBase->VBlankFrequency = vblank[mon];
Enable ();
rc = 0;
}
else
SetIoErr (ERROR_OBJECT_WRONG_TYPE);
}
else
SetIoErr (ERROR_OBJECT_NOT_FOUND);
}
if (!me->pr_CLI && rc)
DisplayBeep (NULL);
CloseLibrary (IntuitionBase);
}
else
Alert (AT_Recovery | AG_OpenLib | AO_Intuition | AN_Unknown);
CloseLibrary ((struct Library *) GfxBase);
}
else
Alert (AT_Recovery | AG_OpenLib | AO_GraphicsLib | AN_Unknown);
if (rc)
FPuts (Output (), "SetDefMon failed!\n");
CloseLibrary (DOSBase);
}
else
Alert (AT_Recovery | AG_OpenLib | AO_DOSLib | AN_Unknown);
if (!me->pr_CLI)
{
Forbid ();
ReplyMsg ((struct Message *) msg);
}
return rc;
}